require 'rubygems'
gem 'OptionParser'

require 'commandline/optionparser'

include CommandLine

basicOptParser = OptionParser.new do |opt|
	opt <<  Option.new(
		:names			=>	["--dbuser", "-U"],
		:arg_arity		=>	[1, 1],
		:opt_description	=>	"Set the database user",
		:opt_not_found		=> 	OptionParser::OPT_NOT_FOUND_BUT_REQUIRED,
		:opt_found 		=> 	OptionParser::GET_ARGS
		)
	opt << Option.new(
		:names			=>	["--dbpasswd", "-W"],
		:arg_arity		=>	[1, 1],
		:opt_description	=>	"Set the database password",
		:opt_not_found		=> 	OptionParser::OPT_NOT_FOUND_BUT_REQUIRED,
		:opt_found 		=> 	OptionParser::GET_ARGS
		)
	opt << Option.new(
		:names			=>	["--dbhost", "-H"],
		:arg_arity		=>	[1, 1],
		:opt_description	=>	"Set the database host",
		:opt_not_found		=> 	OptionParser::OPT_NOT_FOUND_BUT_REQUIRED,
		:opt_found 		=> 	OptionParser::GET_ARGS
		)
	opt <<  Option.new(
		:names			=>	["--dbname", "-D"],
		:arg_arity		=>	[1, 1],
		:opt_description	=>	"Set the database name",
		:opt_not_found		=> 	OptionParser::OPT_NOT_FOUND_BUT_REQUIRED,
		:opt_found 		=> 	OptionParser::GET_ARGS
		)
end

$cmdOptions = nil

begin
	$cmdOptions = basicOptParser.parse(ARGV)
rescue OptionParser::MissingRequiredOptionError => msg
	$stderr.puts msg
	$stderr.puts
	$stderr.puts basicOptParser.to_s

	exit
end

